package org.xbill.DNS.utils;

public class hexdump
{
  private static final char[] hex = "0123456789ABCDEF".toCharArray();

  public static String dump(String paramString, byte[] paramArrayOfByte)
  {
    return dump(paramString, paramArrayOfByte, 0, paramArrayOfByte.length);
  }

  public static String dump(String paramString, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    int i1;
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append(paramInt2 + "b");
    if (paramString != null)
      localStringBuffer.append(" (" + paramString + ")");
    localStringBuffer.append(':');
    int i = 0xFFFFFFF8 & 8 + localStringBuffer.toString().length();
    localStringBuffer.append('\t');
    int j = (80 - i) / 3;
    int k = 0;
    if (k >= paramInt2)
    {
      localStringBuffer.append('\n');
      return localStringBuffer.toString();
    }
    if ((k != 0) && (k % j == 0))
    {
      localStringBuffer.append('\n');
      i1 = 0;
    }
    while (true)
    {
      while (i1 >= i / 8)
      {
        int l = 0xFF & paramArrayOfByte[(k + paramInt1)];
        localStringBuffer.append(hex[(l >> 4)]);
        localStringBuffer.append(hex[(l & 0xF)]);
        localStringBuffer.append(' ');
        ++k;
      }
      localStringBuffer.append('\t');
      ++i1;
    }
  }
}